﻿using Md.Api.Model;
using Md.Api.Model.Web.MdBanner.Request;
using Md.Api.Service.Web.MdBanner;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Web;
/// <summary>
/// PC轮播图管理
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/web/banner")]
public class MdBannerWebController : ControllerBase
{
    /// <summary>
    /// 通过编号获取轮播图服务
    /// </summary>
    public GetMdBannerByIdWebService getMdBannerByIdWebService { get; set; }
    /// <summary>
    /// 通过编号获取轮播图
    /// </summary>
    /// <param name="bannerId">轮播图编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{bannerId}"), AllowAnonymous]
    public async Task<ResponseMessageModel> GetMdBannerByIdWeb(long bannerId, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetMdBannerByIdWebModel();

        model.BannerId = bannerId;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getMdBannerByIdWebService.Execute(model));
    }

    /// <summary>
    /// 获取轮播图列表服务
    /// </summary>
    public GetMdBannerListWebService getMdBannerListWebService { get; set; }
    /// <summary>
    /// 获取轮播图列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost, AllowAnonymous]
    public async Task<ResponseMessageModel> GetMdBannerListWeb([FromBody] RequestGetMdBannerListWebModel model)
    {
        return await Task.Run(() => getMdBannerListWebService.Execute(model));
    }
}

